package com.yan.yjhTest.concurrency.simpleDateFormat;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class NotSafeThread extends Thread{
    private SimpleDateFormat simpleDateFormat;
    /* 要转换的日期字符串 */
    private String dateString;

    public NotSafeThread(SimpleDateFormat simpleDateFormat, String dateString){
        this.simpleDateFormat = simpleDateFormat;
        this.dateString = dateString;
    }

    @Override
    public void run() {
        try {
            Date date = simpleDateFormat.parse(dateString);
            String newDate = simpleDateFormat.format(date).toString();
            if(!newDate.equals(dateString)){
                System.out.println("ThreadName=" + this.getName()
                        + " 报错了，日期字符串：" + dateString
                        + " 转换成的日期为：" + newDate);
            }
        }catch (ParseException e){
            e.printStackTrace();
        }
    }
}
